# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day173_pyqt5_qpen
   Description :   In this example we draw 6 lines using
                   different pen styles.
   Author :       fuml
   date：          2019/10/13
-------------------------------------------------
   Change Activity:
                   2019/10/13:
-------------------------------------------------
"""
import  sys
from  PyQt5.QtWidgets import  QWidget,QApplication
from  PyQt5.QtGui import QFont,QColor,QPainter,QPen
from PyQt5.QtCore import Qt


class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setGeometry(300,300,350,500)
        self.setWindowTitle('QPen')
        self.show()

    def paintEvent(self, QPaintEvent):
        qp = QPainter()
        qp.begin(self)
        self.drawLines(qp)
        qp.end()

    def drawLines(self,qp):
        pen =QPen(Qt.black,2,Qt.SolidLine)

        qp.setPen(pen)
        qp.drawLine(20,40,250,40)

        pen.setStyle(Qt.DashLine)
        qp.setPen(pen)
        qp.drawLine(20,80,250,80)

        pen.setStyle(Qt.DashDotLine)
        qp.setPen(pen)
        qp.drawLine(20,120,250,120)

        pen.setStyle(Qt.DotLine)
        qp.setPen(pen)
        qp.drawLine(20, 160, 250, 160)

        pen.setStyle(Qt.DashDotDotLine)
        qp.setPen(pen)
        qp.drawLine(20, 200, 250, 200)

        pen.setStyle(Qt.CustomDashLine)
        pen.setDashPattern([1,4,5,4])
        qp.setPen(pen)
        qp.drawLine(20,240,250,240)



if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())